import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
// import NavDetail from '@/views/NavDetail'
// import ViewList from '@/views/view/ViewList'
// import Personal from '@/views/Personal'
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
 //导航详情管理
 {
   path:'/nav',
   component:Layout,
   name:'Nav',
   meta:{title:'导航',icon:'el-icon-s-help'},
   children:[
    {
      path:'navdetail',
      component:() => import('@/views/Nav/NavDetail'),
      name:'NavDetail',
      meta:{title: '导航详情管理'}
    },
  ]
 },
 // 新闻列表管理
  {
    path: '/new',
    component: Layout,
    redirect:'/',
    // redirect: '/example/table',
    name: 'News',
    meta: { title: '新闻', icon: 'el-icon-info' },
    children:[
      {
        path:'newslist',
        component:() => import('@/views/news/NewsList'),
        name:'NewsList',
        meta:{title: '新闻列表管理'},
      },
      // {
      //   path:'addOrEditNew',
      //   component:() => import('@/views/news/NewsList/addNewForm'),
      //   name:'addNewForm',
      //   meta:{title: '修改添加'},
      // },
    ]

  },
  //个人中心管理
  {
    path: '/person',
    component: Layout,

    name:'Person',
    meta:{title:'个人中心',icon:'el-icon-user'},

    children:[
      {
        path:'personal',
        component:() => import('@/views/Person/Personal'),
        name:'Personal',
        meta:{title: '个人中心管理'}
      },
    ]
  },
  //设置
  {
    path: '/setting',
    component: Layout,
    // name:'Setting',
    redirect: '/dashboard',
    // component: (Layout) => import('@/views/Setting/index'),
    // meta:{title:'设置',icon:'el-icon-s-help'},
    children: [{
      path: 'setting',
      name: 'Setting',
      component: () => import('@/views/Setting/index'),
      meta: { title: '设置', icon: 'el-icon-setting' }
    }]
  },
  


  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
